//
//  HearTableViewCell.m
//  LoveToListen
//
//  Created by dllo on 16/3/27.
//  Copyright © 2016年 LanOu. All rights reserved.
//

#import "HearTableViewCell.h"

@implementation HearTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.numLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_numLabel];
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:_imgView];
        self.songNameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_songNameLabel];
        self.singerLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_singerLabel];
        self.detailImgV = [[UIImageView alloc] init];
        [self.contentView addSubview:_detailImgV];
        self.countLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_countLabel];
        self.playView = [[UIImageView alloc] init];
        [self.contentView addSubview:_playView];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _numLabel.frame = CGRectMake(20, 0, 30, 30);
    _numLabel.center = CGPointMake(_numLabel.center.x, self.contentView.center.y);
    _numLabel.textAlignment = NSTextAlignmentLeft;
    
    _imgView.frame = CGRectMake(_numLabel.frame.origin.x + _numLabel.frame.size.width + 5, 10, self.contentView.frame.size.height - 20, self.contentView.frame.size.height - 20);
    
    _songNameLabel.frame = CGRectMake(_imgView.frame.origin.x + _imgView.frame.size.width + 15, 15, self.frame.size.width - _imgView.frame.origin.x - _imgView.frame.size.width - 15 - 60, 30);
    
    _singerLabel.frame = CGRectMake(_songNameLabel.frame.origin.x, _songNameLabel.frame.origin.y + _songNameLabel.frame.size.height, 100, 25);
    _singerLabel.textColor = [UIColor grayColor];
    _singerLabel.font = [UIFont systemFontOfSize:14];
    [_singerLabel sizeToFit];
    
    _detailImgV.frame = CGRectMake(_singerLabel.frame.origin.x + _singerLabel.frame.size.width + 5, _singerLabel.frame.origin.y , _singerLabel.frame.size.height , _singerLabel.frame.size.height );
    _detailImgV.contentMode = UIViewContentModeScaleAspectFit;
    _detailImgV.image = [UIImage imageNamed:@"xin"];
    
    _countLabel.frame = CGRectMake(_detailImgV.frame.origin.x + _detailImgV.frame.size.width + 5, _singerLabel.frame.origin.y, 100, _singerLabel.frame.size.height);
    _countLabel.textColor = [UIColor grayColor];
    _countLabel.font = [UIFont systemFontOfSize:14];
    [_countLabel sizeToFit];
    
    if (_countLabel.frame.origin.x + _countLabel.frame.size.width > self.frame.size.width - 60) {
        _singerLabel.frame = CGRectMake(_singerLabel.frame.origin.x, _singerLabel.frame.origin.y, self.frame.size.width - _singerLabel.frame.origin.x - 60 - _detailImgV.frame.size.width - _countLabel.frame.size.width - 5, _singerLabel.frame.size.height);
    }
    
    
    _playView.frame = CGRectMake(self.contentView.frame.size.width - 45, 0, 30, 30);
    _playView.center = CGPointMake(_playView.center.x, self.contentView.center.y);
    _playView.image = [[UIImage imageNamed:@"iconfont-hear-bofang"] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];;
    _playView.tintColor = [UIColor grayColor];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
